import Sequelize from 'sequelize';
import baseDao from '../lib/baseDao.js'; // 数据库操作

const Modal = baseDao.sequelize.define('t_advertise', {
  // 属性
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true, // 主键
    autoIncrement: true, // 自增
    allowNull: true,
    validate: {
      len: [1, 50]
    }
  },
  title: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '广告名称'
  },
  mainPic: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 200]
    },
    comment: '广告主图'
  },
  clickUrl: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 200]
    },
    comment: '点击跳转/复制链接'
  },
  goodsId: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '商品ID，type=2才有'
  },
  line: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '商品内部广告插入行位置'
  },
  materialIds: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 500]
    },
    comment: '官方物料json集合'
  },
  templateType: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '当前物料商品集合所使用的模板ID'
  },
  order: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '广告排序'
  },
  type: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '广告位类型:1轮播，2商品内部'
  },
  expiredAt: {
    type: Sequelize.DATE,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '广告过期时间'
  },
}, {
    // 参数
  });

//向外暴露
export default {
  Modal,
}